package com.zzyl.controller.manager;

import com.zzyl.base.ResponseResult;
import com.zzyl.dto.BedDto;
import com.zzyl.service.BedService;
import com.zzyl.vo.BedVo;
import com.zzyl.vo.RoomTypeVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(path = "/bed")
@Api(tags = "床位管理")
public class BedController {
    @Autowired
    private BedService bedService;

    /**
     * 新增床位
     */
    @PostMapping(path = "/create")
    @ApiOperation("添加床位")
    public ResponseResult<Void> addBed(@RequestBody BedDto bedDto) {
        bedService.addBed(bedDto);
        return ResponseResult.success();
    }

    /**
     * 根据id查找床位详情
     */
    @GetMapping(path = "/read/{id}")
    @ApiOperation("根据id查询床位详情")
    @ApiImplicitParam(name = "id",value = "床位id")
    public ResponseResult<BedVo> findBedTypeById(@PathVariable Long id) {
        BedVo bedVo = bedService.findBedById(id);
        return ResponseResult.success(bedVo);
    }

    /**
     * 更新床位
     */
    @PutMapping(path = "/update")
    @ApiOperation("更新床位信息")
    public ResponseResult<Void> updateBed(@RequestBody BedDto bedDto) {
        bedService.updateBed(bedDto);
        return ResponseResult.success();
    }

    /**
     * 删除床位
     */
    @DeleteMapping(path = "/delete/{id}")
    @ApiOperation("删除床位信息")
    @ApiImplicitParam(name = "id",value = "床位id")
    public ResponseResult<Void> deleteBed(@PathVariable Long id) {
        bedService.deleteBed(id);
        return ResponseResult.success();
    }

}
